<div class="page_heading_text">View Orders</div>
<div class="clear"></div> 

<div class="clear" style="margin-bottom:20px;"></div>
<!-- Start Book Package --> 
<div class="my_account_area_main">
	<span style="font-weight:bold; font-size:24px;"><?=$this->session->userdata('fullname')?></span> 
	Member since <?=mysqldatetime_to_date($this->session->userdata('created'), 'l, F jS Y'); ?> 
</div>
		 
<div class="my_account_area_main">
	<div class="my_account_top_border"></div>
	<div class="my_account_menu_top_border">
		<?php $this->load->view ("includes/my-account-menubar");?>
	</div>
	<div class="orders_profile_main_div">
		<div class="orders_dv1">
			<div class="handler">My order history</div>
			<div class="my_account_heading_div_hei_con">
				<div class="order_heading_profile_field">
					<div class="order_history_heading">Date</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading">Order</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading">Status</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading">Products</div>
				</div>
				<div class="order_heading_profile_field_total">
					<div class="order_history_heading_total">Total</div>
				</div>
				<div class="order_heading_profile_field_edit">
					<div class="order_history_heading_total"></div>
				</div>
			</div>
			<? if($orderArray && count($orderArray) > 0) :?>
				<? foreach ($orderArray as $order_id => $items) :?>
			<!-- Loop Starts -->
			<div class="order_history_main_div">
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down"><?=mysqldatetime_to_date($items[0]['date_of_order'])?></div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down" style="overflow: hidden"><?=$order_id?></div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down"><?=ucfirst($items[0]['status'])?></div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down">
						<?php 
							$products = array();
							foreach ($items as $item) $products[] = $item['book_name'];
							print implode(', ', $products);
						?>
					</div>
				</div>
				<div class="order_heading_profile_field_total">
					<div class="order_history_heading_total_down">
						<?php 
							$total = 0;
							foreach ($items as $item) $total += $item['qty'] * $item['price'];
							print number_format($total, 2, '.', ',');
						?>
					</div>
				</div>
				<div class="order_heading_profile_field_edit">
					<div class="order_history_heading_total_down">
						<div class="order_history_edit_icon">
							<a href="<?=site_url('my-orders/view/'.$order_id)?>">
								<img src="<?=base_url('images/view-icon.gif')?>" width="16" height="16" border="0" alt="View" />
							</a>
						</div>
						<div class="order_history_edit_icon">
							<a href="<?=site_url('my-orders/delete/'.$order_id)?>">
								<img src="<?=base_url('images/delete-icon.png')?>" width="16" height="16" border="0" alt="Delete" />
							</a>
						</div>
					</div>
				</div> 
			</div> 
			<!-- Loop Ends --> 
				<? endforeach;?>
			<? else:?>
			<!-- Loop Starts -->
			<div class="order_history_main_div">
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down">No order available</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down">&nbsp;</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down">&nbsp;</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down">&nbsp;</div>
				</div>
				<div class="order_heading_profile_field_total">
					<div class="order_history_heading_total_down">&nbsp;</div>
				</div>
				<div class="order_heading_profile_field_edit">
					<div class="order_history_heading_total_down">
						<div class="order_history_edit_icon">&nbsp;</div>
						<div class="order_history_edit_icon">&nbsp;</div>
					</div>
				</div> 
			</div> 
			<!-- Loop Ends --> 
			<? endif;?>
		</div>
	</div>
	<div class="clear"></div>
</div>
<div class="clear"></div> 
<div class="clear" style="margin-bottom:20px;"></div> 